<template>
  <div class="practice-item-comp" @click="goDetail">
    <div class="status" v-if="records[cid]">已练习</div>
    <div class="title">{{ title }}</div>
    <div class="info">
      <span>{{ questionCount }}道题</span>
      <template v-if="userCount">
        <span class="item">|</span>
        <span>{{ userCount }}人已参与</span>
      </template>
    </div>
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  props: [
    "cid",
    "title",
    "records",
    "questionCount",
    "userCount",
    "isFree",
    "isVipFree",
    "charge",
    "thumb",
    "category",
  ],
  computed: {
    ...mapState(["isLogin", "user"]),
  },
  methods: {
    ...mapMutations(["showLoginDialog", "changeDialogType"]),
    goLogin() {
      this.changeDialogType(1);
      this.showLoginDialog();
    },
    goDetail() {
      if (!this.isLogin) {
        this.goLogin();
        return;
      }
      this.$router.push({
        name: "ExamPracticeDetail",
        query: {
          id: this.cid,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.practice-item-comp {
  width: 100%;
  height: 116px;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  padding-left: 30px;
  padding-right: 50px;
  margin-bottom: 10px;
  &:hover {
    box-shadow: 0px 4px 8px 0px rgba(102, 102, 102, 0.1);
  }
  .status {
    width: 62px;
    height: 30px;
    background: #f4a529;
    border-radius: 8px 0px 8px 0px;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
  }

  .title {
    height: 16px;
    font-size: 16px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 16px;
  }

  .info {
    height: 30px;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666;
    line-height: 30px;

    .item {
      height: 14px;
      margin-left: 15px;
      margin-right: 15px;
    }
  }
}
</style>